﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using PromotionApp.Model;
using System.Data;
using PromotionApp.DAL;

namespace PromotionApp.BLL
{
    public class LanguageBLL
    {
        #region Private Variable

        private static LanguageBLL _LanguageBLL = null;

        #endregion 

        #region Constructor

        private LanguageBLL()
        {            
        }

        #endregion

        #region Public Method

        public List<Language> GetAllLanguage()
        {
            List<Language> list = new List<Language>();
            DataSet ds = LanguageDAL.GetInstance().GetAllLanguage();

            if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                foreach (DataRow r in ds.Tables[0].Rows)
                {
                    Language o = new Language();
                    o.LanguageCode = r["LanguageCode"].ToString().Trim();
                    o.LanguageName = r["LanguageName"].ToString().Trim();
                    list.Add(o);
                }
            }
            
            return list;
        }

        public static LanguageBLL GetInstance()
        {
            if (_LanguageBLL == null)
                _LanguageBLL = new LanguageBLL();

            return _LanguageBLL;
        }


        #endregion
    }
}